home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 8
/
Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso
/
Aminet
/
comm
/
cnet
/
TrdWars23.lha
/
TwNightlyMaint
< prev
next >
Wrap
Text File
|
1993-08-09
|
18KB
|
777 lines
/* TradeWars 2.3 Nightly Maintenance
Written by Chris Cowan
The Danger Zone (502)/448-1155 (300-19.2k Baud) */
options results
bufferflush
PF = 'PFILES:TRADEWARS/'
PFP = 'PFILES:TRADEWARS/players/'
PFU = 'PFILES:TRADEWARS/universe/'
PFT = 'PFILES:TRADEWARS/teams/'
dir6 = "PFILES:TRADEWARS/text/"
dir7 = "PFILES:TRADEWARS/messages/"
dir8 = "RAM:tw/"
space = ' '
date = date('U')
seed=random(1,100,time('s'))
signal on error
signal on syntax
signal on ioerr
if ~exists('ram:tw') then do;sendstring '$0makedir "ram:tw"}';end
startmaint:
var=0
transmit "f1n1c4 =-= TRADEWARS 2.3 NIGHTLY MAINTENANCE NOW RUNNING =-="
if exists(dir8"Player!") then do
transmit "c1n2There is a player in the game! Waiting until they are done..."
var=1
end
startmaint2:
if exists(dir8"Player!") then do;sendstring "w5";signal startmaint2;end
if var=1 then signal startmaint
call open(file, dir8"Maint!", "W")
an="In Use!"
call writeln file, an
call close(file)
call open(file, PF'_universe.data', 'R')
ns=readln(file)
cbs=readln(file)
call close(file)
call open file, (PF'_config.data'), 'R'
am.1 = readln(file)
am.2 = readln(file)
am.3 = readln(file)
am.4 = readln(file)
am.5 = readln(file)
am.6 = readln(file)
am.7 = readln(file)
am.8 = readln(file)
am.9 = readln(file)
am.10 = readln(file)
am.11 = readln(file)
call close file
filen = PF'_rates.data'
call open file, (filen), 'R'
c.1 = readln(file)
c.2 = readln(file)
call close file
yoopa:
call checkdate
signal sectormaint
checkdate:
If exists(PF'_date.data') then do
call open file, (PF'_date.data'), 'R'
tt.1 = readln(file)
call close file
if tt.1 = date('U') then do
transmit "n1c7Maintenance has already been ran today!"
return
end
end
maint:
dlete:
transmit 'n1c1Deleting Inactive Players...'
call teloop
ur = 0
x = 0
cop = 0
yoop:
x = x + 1
if x > 40 then signal checkvars
user = PFP'p' x
call open file, (user), 'R'
do y = 1 to 31
pl.x.y = readln(file)
end
call close file
signal yoop
checkvars:
x = 0
checkvars2:
x = x + 1
if x > 40 then signal dlete2
if left(pl.x.1,1) = "." then signal checkvars2
do y = 2 to 5
if datatype(pl.x.y) ~= "NUM" then call dataerror
end
do y = 7 to 15
if datatype(pl.x.y) ~= "NUM" then call dataerror
end
do y = 17 to 31
if datatype(pl.x.y) ~= "NUM" then call dataerror
end
signal checkvars2
dataerror:
a = "c1WARNING! A data error has been detected by TwNightlyMaint!!"
b = "Line c7"||y||"c1 of your pfiles:tradewars/players/c7p "||x||"c1 is corrupt!n1"
if exists(dir7"maintlog") then do
call open file, (dir7"maintlog"), "A"
signal dataerror2
end
call open file, (dir7"maintlog"), "W"
dataerror2:
call writeln file, a
call writeln file, b
call close file
return
dlete2:
cop = cop + 1
if cop > 40 then signal interest
bo = pl.cop.14
if left(pl.cop.1,1) = '.' then signal dlete2
if bo = '' then signal dlete2
datc = date('c')
temp = left(pl.cop.1,1)
x = datc - bo
if x > am.6 & temp ~= '.' then do
transmit 'Deleting '||trim(pl.cop.1)||'...'
a = 'c7'pl.cop.1
if pl.cop.15 > 0 then a=a||' c2[c7Team'pl.cop.15'c2]'
a=a||' c6was deleted for inactivity.'
call newspaperopen
if exists(PFU'fighters') then do
call open file, (PFU'fighters'), 'R'
y=0
do until eof(file)
y=y+1
pd.y=readln(file)
if word(pd.y,1)=pl.cop.2 then do
i=y
call cc
end
end
call close file
call searchun
end
pl.cop.3 = 0
pl.cop.4 = 0
pl.cop.7 = 0
pl.cop.2= 0
if pl.cop.15 > 0 then do
teamnumber = pl.cop.15
if tle.teamnumber = pl.cop.1 then do
call disband2
end
end
pl.cop.1 = '..................'
pl.cop.15 = 0
x = cop
call saveuser
if exists(dir7''cop) then address command 'delete 'dir7''cop
if exists(dir7''cop'.msg1') then do
address command 'delete 'dir7''cop'.msg#?'
end
end
signal dlete2
interest:
c.1 = 5
if am.3 = 1 then do
transmit 'n1c3Setting Today''s Interest Rate...'
c.1 = random(1,10)
end
transmit 'Posting Interest...'
cop = 0
inter:
cop = cop + 1
if cop = 41 then signal interend
if pl.cop.13 > 0 then do
x = pl.cop.13
temp = c.1 / 100
y = trunc(x*temp)
x = x + y
pl.cop.13 = x
x = cop
call saveuser
end
signal inter
interend:
c.2 = 75
if am.4 = 1 then do
transmit 'n1c2Setting Today''s Klingon/Romulan Bounty...'
temp = random(0,50)
c.2 = 50 + temp
end
fixnewspaper: /* Crazy Cad gets credit here...*/
xx = 30
if xx = 0 then signal bta
filen = dir7||'newspaper'
if ~exists(filen) then signal bta
call open(short,filen, 'R');s=0
do until eof(short)=1
s=s+1
line.s = readln(short)
end
s=s-1
call close short
if xx ~=0 & xx<s then do
transmit 'n1c7Fixing Newspaper...'
signal off error
call open(short,filen,'W')
do i =(s-xx+1) to s
writeln(short,line.i)
end
call close short
signal on error
end
bta:
v=0
bta2:
v=v+1
if ~exists(dir7'ALL.msg'||v) then signal cabal
call open file, (dir7'ALL.msg'||v||'.index'), 'R'
do z=1 to 7;tt.z = readln(file);end
call close file
d=date('c')
a = d - tt.6
if a < 4 then signal cabal
address command "delete "dir7"ALL.msg"||v
address command "delete "dir7"ALL.msg"||v||".index"
u=v;v=v-1
bta3:
u=u+1;r=u-1
if ~exists(dir7'ALL.msg'||u) then signal bta2
address command "rename "dir7"ALL.msg"||u" as "dir7"ALL.msg"||r
address command "rename "dir7"ALL.msg"||u".index as "dir7"ALL.msg"||r||".index"
signal bta3
cabal:
if exists(dir7'cabal') then do
call open file, (dir7'cabal')
z = readln(file)
call close file
a = 'c7'z' c3Klingons c6& c3Romulans c6were killed yesterday.'
call newspaperopen
address command 'delete 'dir7'cabal'
end
addklingons:
b = date();a = "n1c5Maintenance - "||b||": --n1";if am.1 > 0 then call sysoplog
sendstring "n1c6Replenishing Klingons..."
sector=220
call opensector
sd.9=98
if sd.8 < 50000 then sd.8 = 50000
a = sd.8;a = a + 1000;sd.8 = a
if sd.8 > 100000 then sd.8 = 100000
call closesector
sendstring "."
sector=59
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=310
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=455
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=25
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=395
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=730
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=440
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=68
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=67
call opensector
if sd.9=0 | sd.9=98 then do
sd.9=98;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
moveklingons:
sendstring "n2c3Moving Klingons..."
counter=0
mk2:
counter=counter+1;if counter=6 then signal addromulans
whoops=0
mk3:
whoops=whoops+1;if whoops>200 then do;a = "c1Could not add Klingon group!";if am.1 > 0 then call sysoplog;signal addromulans;end
sector=random(7,999)
if ~exists(PFU'tws'sector) then signal mk3
call opensector
if sd.8>0 & sd.9 ~=98 then signal mk3
if sd.18=3 then signal mk3
sd.9=98;b=random(20,200);sd.8=sd.8+b
call closesector
a = "c6Klingon group added at sector c7"||sector||"c6.";if am.1 > 0 then call sysoplog
sendstring "."
signal mk2
addromulans:
sendstring "n2c5Replenishing Romulans..."
sector=560
call opensector
sd.9=99
if sd.8 < 50000 then sd.8 = 50000
a = sd.8;a = a + 1000;sd.8 = a
if sd.8 > 100000 then sd.8 = 100000
call closesector
sendstring "."
sector=54
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=920
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=735
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=185
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=615
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=425
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=81
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=73
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=37
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=13
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=14
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=38
call opensector
if sd.9=0 | sd.9=99 then do
sd.9=99;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
moveromulans:
sendstring "n2c4Moving Romulans..."
counter=0
mr2:
counter=counter+1;if counter=6 then signal addfederation
whoops=0
mr3:
whoops=whoops+1;if whoops>200 then do;a = "c1Could not add Romulan group!";if am.1 > 0 then call sysoplog;signal addfederation;end
sector=random(7,999)
if ~exists(PFU'tws'sector) then signal mr3
call opensector
if sd.8>0 & sd.9 ~=99 then signal mr3
if sd.18=2 then signal mr3
sd.9=99;b=random(20,200);sd.8=sd.8+b
call closesector
a = "c3Romulan group added at sector c7"||sector||"c3.";if am.1 > 0 then call sysoplog
sendstring "."
signal mr2
addfederation:
sendstring "n2c7Replenishing Federation ships..."
sector=1
call opensector
sd.9=97
if sd.8 < 50000 then sd.8 = 50000
a = sd.8;a = a + 1000;sd.8 = a
if sd.8 > 100000 then sd.8 = 100000
call closesector
sendstring "."
sector=89
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=320
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=365
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=955
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=61
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=49
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=75
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=48
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=26
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=80
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=610
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
sector=890
call opensector
if sd.9=0 | sd.9=97 then do
sd.9=97;a = sd.8;a = a + 100;sd.8 = a;if sd.8 > 1000 then sd.8 = 1000;call closesector
end
sendstring "."
moveborg:
borgsector=0
transmit "f1n1c4 =-= TRADEWARS 2.3 NIGHTLY MAINTENANCE NOW RUNNING =-="
transmit "n1c1Moving the Borg..."
if exists(PF'_borg.data') then do
call open file, (PF'_borg.data'), 'R'
borgsector = readln(file)
call close file
end
moveborg2:
var=random(7,999)
if var=borgsector then signal moveborg2
if ~exists(PFU"tws"||var) then signal moveborg2
call open file, (PF'_borg.data'), 'W'
call writeln file, var
call close file
a = "c2Borg moved to sector c7"||var||"c2.";if am.1 > 0 then call sysoplog
moveq:
qsector=0
transmit "n1c2Moving Q..."
if exists(PF'_q.data') then do
call open file, (PF'_q.data'), 'R'
qsector = readln(file)
call close file
end
moveq2:
var=random(7,999)
if var=borgsector then signal moveq2
if var=qsector then signal moveq2
if ~exists(PFU"tws"||var) then signal moveq2
call open file, (PF'_q.data'), 'W'
call writeln file, var
call close file
a = "c4Q moved to sector c7"||var||"c4.";if am.1 > 0 then call sysoplog
addasteroid:
transmit "n1c7Adding Asteroids..."
x=0;var=random(1,3)
aa2:
x=x+1;if x>var then signal checkcloaking
whoops=0
aa3:
whoops=whoops+1;if whoops>200 then do;a = "c1Could not add Asteroid!";if am.1 > 0 then call sysoplog;signal checkcloaking;end
sector=random(7,999)
if ~exists(PFU'tws'sector) then signal aa3
call opensector
sd.19=sd.19+1
call closesector
a = "c5Asteroid added at sector c7"||sector||"c5.";if am.1 > 0 then call sysoplog
signal aa2
checkcloaking:
transmit "n1c6Checking for expired cloaking devices..."
x=0
checkcloak2:
x=x+1;if x=41 then signal done
user=PFP'p' x
call open file, (user), 'R'
do y=1 to 31
pl.x.y=readln(file)
end
call close file
if pl.x.18 > 0 then do
a=pl.x.18;a=a-1;pl.x.18=a
call saveuser
if pl.x.18=0 then transmit "n1c7The U.S.S. "||pl.x.16||" materializes!"
end
signal checkcloak2
done:
if exists(PF'_date.data') then address command 'delete 'PF'_date.data'
fle = PF'_date.data'
call open file, (fle), 'W'
call writeln file, date('U')
call close file
if exists(PF'_rates.data') then address command 'delete 'PF'_rates.data'
fle = PF'_rates.data'
call open file, (fle), 'W'
call writeln file, c.1
call writeln file, c.2
call close file
endcheck:
return
opensector:
call open(sctor,PFU'tws'sector, 'R')
do yop=1 to 19
sd.yop=readln(sctor)
end
call close(sctor)
return
closesector:
call open(sctor,PFU'tws'sector, 'W')
do yop=1 to 19
call writeln(sctor, sd.yop)
end
call close(sctor)
return
error:
transmit 'n1Error in Line #' SIGL
signal endit
syntax:
a = SIGL
transmit 'n1Syntax Error In Line #' a
transmit 'Line Reads : >'sourceline(a)'<'
signal endit
ioerr:
transmit 'n1I/O Error In Line #' SIGL
signal endit
saveuser:
call open file, (PFP'p' x), 'W'
do y = 1 to 31
call writeln file, pl.x.y
end
call close file
return
cnter:
sendstring center(an,linelength)
return
newspaperopen:
if exists(dir7'newspaper') then do
call close file
call open file, (dir7'newspaper'), 'A'
call writeln file, a
call close file
return
end
call close file
call open file, (dir7'newspaper'), 'W'
call writeln file, a
call close file
return
sysoplog:
if exists(dir7'sysoplog') then do
call close file
call open file, (dir7'sysoplog'), 'A'
call writeln file, a
call close file
return
end
call close file
call open file, (dir7'sysoplog'), 'W'
call writeln file, a
call close file
return
disband2:
teamnumber = pl.cop.15
transmit 'n1c2Disbanding Team...'
x = 0
do x = 1 to 40
if pl.x.15 = teamnumber then do
pl.x.15 = 0
call saveuser
end
end
a = 'c7'tn.teamnumber' c2disbanded due to the deletion of the captain.'
call newspaperopen
tn.teamnumber = '..'
call saveteam
teloop:
x = 0
teloop2:
x=x+1
if x>10 then return
fle=PFT't' x
call open file, (fle), 'R'
tn.x = readln(file)
tle.x = readln(file)
tpd.x = readln(file)
call close file
signal teloop2
saveteam:
fle = PFT't 'teamnumber
call open file, (fle), 'W'
call writeln file, tn.teamnumber
call writeln file, tle.teamnumber
call writeln file, tpd.teamnumber
call close file
return
searchun:
i=0
searchun2:
i=i+1
if i>y then return
if word(pd.i,1)=pl.cop.2 then do
call removef
i=i-1
end
signal searchun2
cc:
sector=word(pd.i,2)
call open(sctor,PFU'tws'sector, 'R')
do yop=1 to 19
sd.yop=readln(sctor)
end
call close(sctor)
var=random(1,2)
if var=1 then sd.9=98
if var=2 then sd.9=99
call open(sctor,PFU'tws'sector, 'W')
do yop=1 to 19
call writeln(sctor, sd.yop)
end
call close(sctor)
return
removef:
z=0
removef2:
z=z+1
temp=y+1
if z=temp then signal removef3
temp=i+z
an=i+z-1
pd.an=pd.temp
signal removef2
removef3:
y=y-2
call open file, (PFU'fighters'), 'W'
do z=1 to y
call writeln file, pd.z
end
call close file
return
newspaperprint:
if exists(dir7'newspaper') then call open(file, dir7'newspaper', 'A')
if ~exists(dir7'newspaper') then call open(file, dir7'newspaper', 'W')
call writeln file, a
call close(file)
drop a
return
endit:
sendstring '$0delete 'dir8'Maint!}'
exit
sectormaint:
transmit "n2c4NIGHTLY MAINTENANCE COMPLETE!"
signal endit